package com.ruoyi.web.controller.cs;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BasicsController;
import com.ruoyi.common.core.domain.Response;
import com.ruoyi.common.core.page.ResponsePageInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cs.domain.TRedbagOpen;
import com.ruoyi.cs.domain.vo.TRollCyVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.cs.domain.TRollCy;
import com.ruoyi.cs.service.ITRollCyService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ROLL房间参与Controller
 *
 * @author ruoyi
 * @date 2021-03-25
 */
@Api(tags = {"ROLL房间信息"})
@RestController
@RequestMapping("/cs/rollcy")
public class TRollCyController extends BasicsController
{
    @Autowired
    private ITRollCyService tRollCyService;

    /**
     * 后台奖品记录
     */
    @ApiOperation("后台奖品记录")
    @PreAuthorize("@ss.hasPermi('cs:cy:prizeListBack')")
    @RequestMapping(name="查询ROLL房间参与列表",value="prizeListBack",method = RequestMethod.POST)
    public ResponsePageInfo<TRollCyVo> prizeListBack(TRollCyVo tRollCyVo)
    {
        startPage(tRollCyVo.getPageNum(),tRollCyVo.getPageSize());
        List<TRollCyVo> list = tRollCyService.prizeListBack(tRollCyVo);
        return toResponsePageInfo(list);
    }
    /**
     * 后台ROLL房参与记录
     */
    @ApiOperation("后台ROLL房参与记录")
    @PreAuthorize("@ss.hasPermi('cs:cy:partakeRecodeList')")
    @RequestMapping(name="后台ROLL房参与记录",value="partakeRecodeList",method = RequestMethod.POST)
    public ResponsePageInfo<TRollCyVo> partakeRecodeList(@RequestBody  TRollCyVo tRollCyVo)
    {
        String sort = "a.goodsPrice asc";
        if ("1".equals(tRollCyVo.getSort())){
            sort = "a.goodsPrice desc";
        }
        startPage(tRollCyVo.getPageNum(),tRollCyVo.getPageSize(),sort);
        List<TRollCyVo> list = tRollCyService.partakeRecodeList(tRollCyVo);
        return toResponsePageInfo(list);
    }

    /**
     * 批量指定开奖饰品
     */
    @ApiOperation("批量指定开奖饰品")
    @PreAuthorize("@ss.hasPermi('cs:cy:batchAppointGoodsId')")
    @RequestMapping(name="批量指定开奖饰品",value="batchAppointGoodsId",method = RequestMethod.POST)
    @Log(title = "指定开奖饰品", businessType = BusinessType.INSERT)
    public Response batchAppointGoodsId(@RequestBody List<TRollCy> list)
    {
        return tRollCyService.batchAppointGoodsId(list);
    }

    /**
     * ROLL房指定饰品列表
     * @param goodsBelongingId
     * @return
     */
    @ApiOperation("ROLL房指定饰品列表")
    @PreAuthorize("@ss.hasPermi('cs:cy:appointGoodsList')")
    @RequestMapping(name="ROLL房指定饰品列表",value="appointGoodsList",method = RequestMethod.GET)
    @ApiImplicitParam(name = "goodsBelongingId",value = "饰品所属箱子ID" , dataType = "String", paramType = "query", required = true)
    public Response<List<Map>> appointGoodsList(String  goodsBelongingId)
    {
        List<Map> list = tRollCyService.appointGoodsList(goodsBelongingId);
        return Response.success(list);
    }

    /**
     * 添加ROLL房指定参与用户
     */
    @ApiOperation("添加ROLL房指定参与用户")
    @PreAuthorize("@ss.hasPermi('system:cy:addAppointUser')")
    @Log(title = "添加ROLL房指定参与用户", businessType = BusinessType.INSERT)
    @RequestMapping(name="添加ROLL房指定参与用户",value="addAppointUser",method = RequestMethod.GET)
    public Response addAppointUser(@RequestParam(value = "userPhone") String userPhone,
                                   @RequestParam(value = "rollId") String rollId)
    {
        return tRollCyService.addAppointUser(userPhone,rollId);
    }

}
